<template>
	<div class="edu-page-warp">
		<condition-card @reset="reset" @search="onSubmit">
			<el-row :gutter="24">
				<el-col :span="8">
					<el-form-item :label="$t('teachers.facultyLabel')">
						<el-select v-model="queryForm.faculty" filterable>
							<el-option
								v-for="item in options.college"
								:key="item.value"
								:label="item.label"
								:value="item.value"
							></el-option>
						</el-select>
					</el-form-item>
				</el-col>
			</el-row>
		</condition-card>
		<div class="edu-page-title mg-top"></div>
		<el-card shadow="never">
			<div class="edu-page-title">{{$t('teachers.inServiceTeacher')}}</div>
			<div class="edu-opertion-bar" style="margin-bottom: 16px;">
				<div class="float-right">
					<el-button type="primary" @click="exportTitle">{{$t("message.export")}}</el-button>
				</div>
			</div>
			<el-table stripe :data="viewData" size="mini" width="100%" tooltip-effect="light">
				<edu-table-column :label="$t('message.order')" type="index" width="50"/>
				<edu-table-column prop="faculty" :label="$t('teachers.facultyCode')" />
				<edu-table-column prop="facultyI18n" :label="$t('label.college')" />
				<edu-table-column prop="professor" :label="$t('teachers.professor')" />
				<edu-table-column
					prop="associateProfessor"
					:label="$t('teachers.associateProfessor')"

				/>
				<edu-table-column prop="junior" :label="$t('teachers.primaryTitle')" />
				<edu-table-column
					prop="intermediate"
					:label="$t('teachers.intermediateTitle')"

				/>
				<edu-table-column prop="senior" :label="$t('teachers.seniorTitle')" />
				<edu-table-column :label="$t('message.operating')">
					<template slot-scope="scope">
						<el-button
							type="text"
							size="mini"
							@click="exportDetail(scope.row)"
						>{{$t('teachers.exportDetail')}}</el-button>
					</template>
				</edu-table-column>
			</el-table>
			<el-row>
				<el-col>
					<el-pagination
						@size-change="handleSizeChange"
						@current-change="handleCurrentChange"
						:current-page="queryForm.pageNum_"
						:page-sizes="[20,50,100,500,1000]"
						:page-size="queryForm.pageSize_"
						layout="total, sizes, prev, pager, next, jumper"
						:total="queryForm.total_"
						style="float:right;margin-top:10px"
					></el-pagination>
				</el-col>
			</el-row>
		</el-card>
	</div>
</template>
<script>
import {
	statisticsTitle,
	exportTitle,
	exportFacultyTitle
} from "common/src/api/resource/teachers";

import { findAllDeptList } from "common/src/api/user";
import { queryDic } from "common/src/api/dictionary";
import UTILS from "common/src/utils/utils";
export default {
	name: "",
	data() {
		return {
			queryForm: {
				faculty: "",
				pageNum_: 1,
				pageSize_: 20,
				total_: 0
			},
			options: {
				college: []
			},
			viewData: []
		};
	},
	mounted: function() {
		this.init();
	},
	methods: {
		init() {
			//筛选条件字典查询
			/*let data = {
				lang: this.$store.getters.language || "cn",
				type: "allChild",
				keys: ["X_YX"]
			};
			queryDic(data).then(res => {
				if (res.code == 200) {
					UTILS.fillSelect(
						{
							college: "X_YX"
						},
						res.data,
						this.options
					);
				}
			});*/
			findAllDeptList(1).then(res => {
        if (res.code == 200) {
          for (const item of res.data) {
            this.options.college.push({
              label: item.deptName,
              value: item.deptCode
            });
          }
        }
      });


			this.onSubmit();
		},
		onSubmit() {
			this.getDataList();
		},
		reset() {
			this.queryForm.faculty = "";
			this.onSubmit();
		},
		getDataList(isFirstPage = true) {
			if (isFirstPage) {
				this.queryForm.pageNum_ = 1;
			}
			statisticsTitle(this.queryForm).then(res => {
				if (res.code == 200) {
					this.viewData = res.data.list;
					this.queryForm.total_ = res.data.total_;
				}
			});
		},
		handleSizeChange(val) {
			this.queryForm.pageSize_ = val;
			this.getDataList();
		},
		handleCurrentChange(val) {
			this.queryForm.pageNum_ = val;
			this.getDataList(false);
		},
		exportTitle() {
			exportTitle(this.queryForm);
		},
		exportDetail(row) {
			exportFacultyTitle({
				faculty: row.faculty
			});
		}
	}
};
</script>
<style lang="scss" scoped>
</style>
